<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script language="JavaScript">

    $(function () {
        if ($('#approvalState').val() == 'PENDING' && (  (  ($('#userRole').val() == 'ORDS') ) || (  ($('#editMode').val() != 1)  &&   ($('#userRole').val() == 'ORIP')   ) ) ){
            disablePersonalInformation();
            //  $('#addChild').hide();
        }
    });

    $(document).ready(function () {

        setDatePicker();
        validatePersonalDetails();

    });

    function setDatePicker() {
        var dO = new Date();
        var d = dO.getDate();
        var m = dO.getMonth();
        var y = dO.getFullYear();
        var today = y + "-" + m + "-" + d;
        var id;
        $('.childDOB').DatePicker({
            format:'Y-m-d',
            date:dO,
            current:dO,
            position:'right',
            onBeforeShow:function () {
                id = "#" + this.id;
                $('.childDOB').DatePickerSetDate(dO, true);
            },
            onChange:function (formated, dates) {

                $(id).val(formated);

            }
        });
    }

    function disablePersonalInformation() {
        var fields = new Array(
                'name',
                'dateOfBirth',
                'holderGender',
                'designation',
                'address',
                'nic',
                'mobile',
                'landPhone',
                'email',
                'fax',
                'spouse',
                'successor'
                );
        enableFields(fields);
    }

    function validatePersonalDetails() {

        //Mobile
        $('#mobile').rules("add", {
            phoneNo:true,
            messages:{
                phoneNo:$('#pls_enter_valid_phone_no').val()}
        });


        //Land Line
        $('#landPhone').rules("add", {
            phoneNo:true,
            messages:{
                phoneNo:$('#pls_enter_valid_phone_no').val()}
        });

        //Fax
        $('#fax').rules("add", {
            phoneNo:true,
            messages:{
                phoneNo:$('#pls_enter_valid_fax_no').val()}
        });

        //E-mail
        $('#email').rules("add", {
            email:true,
            messages:{
                email:$('#pls_enter_valid_email').val()}
        });
    }

</script>
<tr>
    <td><s:label value="%{getText('name_of_holder.label')}"/><span class="mandatory-field"></span></td>
    <td colspan="3"><s:textfield id="name" name="alienation.holder.name" cssClass="width-595-px" rows="1"/></td>
</tr>
<tr>
    <td><s:label value="%{getText('date_of_birth.label')}"/> <s:label value="%{getText('date_format.label')}"
                                                                      cssClass="date-format"/></td>
    <td><s:textfield id="dateOfBirth" name="alienation.holder.dateOfBirth" onclick="selectDate('dateOfBirth')"
                     cssClass="width-200-px" onKeyPress="return dateNumbersOnly(event,true)"/></td>
    <td><s:label value="%{getText('gender.label')}"/></td>
    <td><s:select id="holderGender"
                  list="#@java.util.HashMap@{'1':getText('female.label'), '0':getText('male.label')}"
                  name="alienation.holder.gender" cssClass="width-200-px"/></td>
</tr>
<tr>
    <td><s:label value="%{getText('occupation.label')}"/></td>
    <td colspan="3"><s:textfield id="designation" name="alienation.holder.designation" cssClass="width-595-px"
                                 rows="1"/></td>
</tr>
<tr>
    <td><s:label value="%{getText('address.label')}"/></td>
    <td colspan="3"><s:textarea id="address" name="alienation.holder.contacts.address" cssClass="width-595-px"
                                rows="1"/></td>
</tr>
<tr>
    <td colspan="2"><s:label value="%{getText('NIC_reg_number.label')}"/></td>
    <td colspan="2"><s:textfield id="nic" name="alienation.holder.registrationNumberOrNIC"
                                 cssClass="width-200-px"/></td>
</tr>
<tr>
    <%--<td><s:label value="%{getText('contact_number.label')}"/></td>--%>
    <td><s:label value="%{getText('mobile.label')}"/></td>
    <td><s:textfield id="mobile" name="alienation.holder.contacts.mobile" cssClass="width-200-px"
                     onKeyPress="return numbersonly(event,true)"/></td>
    <td><s:label value="%{getText('land_line.label')}"/></td>
    <td><s:textfield id="landPhone" name="alienation.holder.contacts.landPhone" cssClass="width-200-px"
                     onKeyPress="return numbersonly(event,true)"/></td>
</tr>
<tr>
    <td><s:label value="%{getText('email.label')}"/></td>
    <td><s:textfield id="email" name="alienation.holder.contacts.email" cssClass="width-200-px"/></td>
    <td><s:label value="%{getText('fax.label')}"/></td>
    <td><s:textfield id="fax" name="alienation.holder.contacts.fax" cssClass="width-200-px"
                     onKeyPress="return numbersonly(event,true)"/></td>
</tr>
<tr>
    <td><s:label value="%{getText('name_of_spouse.label')}"/></td>
    <td colspan="3"><s:textfield id="spouse" name="alienation.holder.spouse" cssClass="width-595-px" rows="1"/></td>
</tr>
<s:include value="../childrenDetails.jsp"/>

<s:hidden id="child-name" value="%{getText('name.label')}"/>
<s:hidden id="child-dob" value="%{getText('dob.label')}"/>
<s:hidden id="select_gender" value="%{getText('select_gender.label')}"/>
<s:hidden id="male-label" value="%{getText('male.label')}"/>
<s:hidden id="female-label" value="%{getText('female.label')}"/>
<s:hidden id="unknown-label" value="%{getText('unknown.label')}"/>
<s:hidden id="gender-label" value="%{getText('gender.label')}"/>

<s:hidden id="delete" value="%{getText('delete.label')}"/>
<s:hidden id="pls_enter_holder_name" value="%{getText('pls_enter_holder_name.label')}"/>